#region Microsoft Public License
/*
 * (c) Copyright Chenjun Wu. http://utablesdk.codeplex.com
 * 
 * This source is subject to the Microsoft Public License (Ms-PL).
 * Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
 * All other rights reserved.
 */
#endregion

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using UTable.Input;
using UTable.Input.MultiTouch;
using UTable.Objects;
using UTable.Objects.Controls;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Reflection;
using System.Collections.ObjectModel;

namespace UTable.Objects
{
	/// <summary>
	/// Interaction logic for UDining.xaml
	/// </summary>
	public partial class UDining : UTabletop
	{
        public ObservableCollection<UApplicationAbstract> _applications = new ObservableCollection<UApplicationAbstract>();

        public ObservableCollection<UApplicationAbstract> Applications
        {
            get { return _applications; }
        }

		public UDining()
		{
			InitializeComponent();
            AppGrid.ItemTapped += new UGridViewEventHandler(AppGrid_ItemTapped);
            this.DataContext = this;

            this.AppGrid.Loaded += new RoutedEventHandler(UDining_Loaded);
		}

        void UDining_Loaded(object sender, RoutedEventArgs e)
        {
            UAppLoader.LoadAppsFromDirectory("Apps", _applications);
        }

        void AppGrid_ItemTapped(UGridViewPanel sender, UGridViewEventArgs args)
        {
            UApplicationAbstract appAbs = args.Item.DataContext as UApplicationAbstract;
            ObjectCreateParameter appParam = new ObjectCreateParameter(appAbs.MainObjectType);
            IObject app = UTableHelper.CreateObject(appParam);
            app.LayoutState = ObjectLayoutState.Maximized;
            app.Owner = this;
        }
	}
}